package com.example.config;

import com.example.interceptor.UserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//xml
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

//    mvc:interceptors
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

//        mvc:interceptor
//        刚才的过滤器类，要过滤的目录，目录里不要过滤的url,不是所有的请求都需要拦截
        registry.addInterceptor(new UserInterceptor()).addPathPatterns("/user/**").excludePathPatterns("/user/out","/user/error","/user/login");
    }
}
